package com.ljx.recruitment.datapatch.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ljx.recruitment.common.datapatch.DataPatch;
import com.ljx.recruitment.common.exception.ApiException;
import com.ljx.recruitment.datapatch.mapper.DataPatchMapper;
import com.ljx.recruitment.common.datapatch.DataPatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DataPatchServiceImpl extends ServiceImpl<DataPatchMapper, DataPatch> implements DataPatchService {

    @Autowired
    private DataPatchMapper dataPatchMapper;

    @Override
    public DataPatch getByName(String name) {
        if (StrUtil.isEmpty(name)) {
            throw new ApiException("datapatch name不能为空");
        }
        return dataPatchMapper.selectOne(new LambdaQueryWrapper<DataPatch>()
                .eq(DataPatch::getName, name));
    }
}
